package com.gopay.common.oldmermove.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.domain.oldmermove.OldMovedMerTranLog;
import com.gopay.common.oldmermove.dao.OldMovedMerTranLogDAO;
/**
 * 老平台迁移商户交易记录
 * @OldMovedMerTranLogDAOImpl.java
 * @author lizheng
 * @2014-7-3 下午4:22:49  www.gopay.com.cn Inc.All rights reserved.
 */
@Repository("oldMovedMerTranLogDAO")
public class OldMovedMerTranLogDAOImpl extends BaseDAOImpl<OldMovedMerTranLog, Serializable> implements OldMovedMerTranLogDAO {

	/**
	 * 根据老平台商户ID、商户订单号查询交易记录
	 */
	@Override
	public List<OldMovedMerTranLog> getByMerIdAndOrderNo(String merId, String orderNo) {
		DetachedCriteria criteria = DetachedCriteria.forClass(OldMovedMerTranLog.class);
		criteria.add(Restrictions.eq("merId", merId));
		criteria.add(Restrictions.eq("merOrderNo", orderNo));
		criteria.addOrder(Order.desc("transSq"));
		return this.findByCriteria(criteria);
	}

    @Override
    public List<OldMovedMerTranLog> getByMerIdAndMerTxnCd(String merId, String merTxnCd) {
        DetachedCriteria criteria = DetachedCriteria.forClass(OldMovedMerTranLog.class);
        criteria.add(Restrictions.eq("merId", merId));
        criteria.add(Restrictions.eq("tranCode", merTxnCd));
        criteria.addOrder(Order.desc("transSq"));
        return this.findByCriteria(criteria);
    }
}
